import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import app from './modules/app'
import settings from './modules/settings'
import user from './modules/user'
import permission from './modules/permission'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
  // 专门用来声明全局变量的地方
    msg: '666'
  },
  mutations: {
  // 专门修改state声明的变量属性值得地方
  // 默认的第一个参数是state
  // 要加额外的参数就放在第二
    setMsg(state, data) {
      state.msg = data
    }
  },
  actions: {
    changemasg(store) {
      setTimeout(() => {
        store.commit('setMsg', 879)
      }, 1000)
    }
  },

  modules: {
    app,
    settings,
    user,
    permission
  },
  getters
})

export default store
